/*
 * Academic License - for use in teaching, academic research, and meeting
 * course requirements at degree granting institutions only.  Not for
 * government, commercial, or other organizational use.
 *
 * File: Schedul_10msTask.c
 *
 * Code generated for Simulink model 'SMO_Arctan_FOC'.
 *
 * Model version                  : 2.7
 * Simulink Coder version         : 9.8 (R2022b) 13-May-2022
 * C/C++ source code generated on : Fri Oct 11 14:25:16 2024
 *
 * Target selection: ert.tlc
 * Embedded hardware selection: Intel->x86-64 (Windows64)
 * Code generation objectives: Unspecified
 * Validation result: Not run
 */

#include "rtwtypes.h"
#include "Schedul_10msTask.h"
#include "SMO_Arctan_FOC.h"

/* Named constants for Chart: '<S3>/Chart' */
#define SMO_Arctan_FOC_IN_CLL          ((uint8_T)1U)
#define SMO_Arctan_FOC_IN_Init         ((uint8_T)2U)
#define SMO_Arctan_FOC_IN_OPL          ((uint8_T)3U)

/* Enable for function-call system: '<S1>/Schedul_10msTask' */
void SMO_Arc_Schedul_10msTask_Enable(void)
{
  /* Enable for Chart: '<S3>/Chart' */
  SMO_Arctan_FOC_DW.previousTicks = SMO_Arctan_FOC_M->Timing.clockTick1;
}

/* Output and update for function-call system: '<S1>/Schedul_10msTask' */
void SMO_Arctan_FOC_Schedul_10msTask(void)
{
  uint32_T elapsedTicks;

  /* Chart: '<S3>/Chart' */
  elapsedTicks = SMO_Arctan_FOC_M->Timing.clockTick1 -
    SMO_Arctan_FOC_DW.previousTicks;
  SMO_Arctan_FOC_DW.previousTicks = SMO_Arctan_FOC_M->Timing.clockTick1;
  if (SMO_Arctan_FOC_DW.temporalCounter_i1 + elapsedTicks <= 63U) {
    SMO_Arctan_FOC_DW.temporalCounter_i1 = (uint8_T)
      (SMO_Arctan_FOC_DW.temporalCounter_i1 + elapsedTicks);
  } else {
    SMO_Arctan_FOC_DW.temporalCounter_i1 = 63U;
  }

  if (SMO_Arctan_FOC_DW.is_active_c1_SMO_Arctan_FOC == 0U) {
    SMO_Arctan_FOC_DW.is_active_c1_SMO_Arctan_FOC = 1U;
    SMO_Arctan_FOC_DW.is_c1_SMO_Arctan_FOC = SMO_Arctan_FOC_IN_Init;
    SMO_Arctan_FOC_DW.temporalCounter_i1 = 0U;
    SMO_Arctan_FOC_B.Motor_State = 0.0;
  } else {
    switch (SMO_Arctan_FOC_DW.is_c1_SMO_Arctan_FOC) {
     case SMO_Arctan_FOC_IN_CLL:
      SMO_Arctan_FOC_B.Motor_State = 2.0;
      SMO_Arctan_FOC_DW.time = 0.0;
      break;

     case SMO_Arctan_FOC_IN_Init:
      if (SMO_Arctan_FOC_DW.temporalCounter_i1 >= 50U) {
        SMO_Arctan_FOC_DW.is_c1_SMO_Arctan_FOC = SMO_Arctan_FOC_IN_OPL;
        SMO_Arctan_FOC_B.Motor_State = 1.0;
        SMO_Arctan_FOC_DW.time++;
      } else {
        SMO_Arctan_FOC_B.Motor_State = 0.0;
      }
      break;

     default:
      /* case IN_OPL: */
      if ((SMO_Arctan_FOC_DW.time > 100.0) && (SMO_Arctan_FOC_B.Delay > 900.0F))
      {
        SMO_Arctan_FOC_DW.is_c1_SMO_Arctan_FOC = SMO_Arctan_FOC_IN_CLL;
        SMO_Arctan_FOC_B.Motor_State = 2.0;
        SMO_Arctan_FOC_DW.time = 0.0;
      } else {
        SMO_Arctan_FOC_B.Motor_State = 1.0;
        SMO_Arctan_FOC_DW.time++;
      }
      break;
    }
  }

  /* End of Chart: '<S3>/Chart' */
}

/*
 * File trailer for generated code.
 *
 * [EOF]
 */
